package cool.mtc.minghe.data.model.sys.org.form;

import cool.mtc.minghe.data.entity.sys.org.OrgDO;
import cool.mtc.web.model.form.LongIdFormSupport;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import org.springframework.beans.BeanUtils;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;

/**
 * @author yz
 */
@Schema(description = "表单")
@Data
public class OrgForm implements LongIdFormSupport {

    @Schema(description = "ID")
    private Long orgId;

    @Schema(description = "父级单位")
    private Long orgParentId;

    @Schema(description = "编码")
    private String code;

    @Schema(description = "名称")
    @NotBlank(message = "org.name.required")
    private String name;

    @Schema(description = "全名")
    private String longName;

    @Schema(description = "排序")
    private Integer orderIndex;

    @Schema(description = "类型")
    @NotNull(message = "org.type.required")
    private Long typeId;

    @Schema(description = "是否是虚拟的")
    private Boolean virtual;

    @Override
    public Long getId() {
        return orgId;
    }

    public OrgDO transToDO() {
        OrgDO orgDO = new OrgDO();
        this.updateDO(orgDO);
        return orgDO;
    }

    public void updateDO(OrgDO orgDO) {
        BeanUtils.copyProperties(this, orgDO);
    }
}
